package com.zipeng.entity;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: zipeng Li
 * 2021/4/27  10:34
 *
 * 自定义返回结果
 */
@Data
public class R {
    /**
     * 描述信息
     */
    private String msg;
    /**
     * 返回的数据
     */
    private Map<String, Object> data = new HashMap<>();

    public static R success(){
        R r = new R();
        r.setMsg("成功");
        return r;
    }

    public static R error(){
        R r = new R();
        r.setMsg("失败");
        return r;
    }

    public R message(String msg){
        this.msg = msg;
        return this;
    }

    public R data(String key, Object value){
        this.data.put(key, value);
        return this;
    }
}
